//
//  MeatPaySuccessViewController.m
//  PigMarket
//
//  Created by 张敬 on 2019/7/29.
//  Copyright © 2019年 pigmarket.oc. All rights reserved.
//

#import "MeatPaySuccessViewController.h"

@interface MeatPaySuccessViewController ()

@property (nonatomic, strong) UIImageView *successIcon;
@property (nonatomic, strong) UILabel *mainLab;
@property (nonatomic, strong) UILabel *detailLab;

@end

@implementation MeatPaySuccessViewController

#pragma mark - view life cycle

- (void)setupUI
{
    self.baseNavView.navTitleLabel.text = @"支付成功";
    
    self.view.backgroundColor = KWhiteColor;
    [self.view addSubview:self.successIcon];
    [self.view addSubview:self.mainLab];
    [self.view addSubview:self.detailLab];
    
}

- (void)setupLayout
{
    
    _successIcon.mj_y = self.baseNavView.bottom+70;
    _mainLab.mj_y = _successIcon.bottom + 15;
    _detailLab.mj_y = _mainLab.bottom + 8;
    
    NSArray *titles = @[@"查看订单", @"继续逛逛"];
    NSArray *colors = @[UIColorFromRGB(0x454545), KWhiteColor];
    
    @weakify(self);
    [titles enumerateObjectsUsingBlock:^(id  _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
        @strongify(self);
        UIButton *button = [UIButton makeButtonWithText:obj textColor:colors[idx] font:mFont(14) textAliment:1 cornerRadius:18];
        button.size = CGSizeMake(126, 36);
        button.mj_y = self.detailLab.bottom + 32;
        button.mj_x = (KScreenWidth - 126*2 - 20)/2.0 + 146*idx;
        
        if (idx == 0) {
            button.layer.borderColor = mMainColor.CGColor;
            button.layer.borderWidth = 1;
        }else{
            [button setBackgroundImage:[UIImage imageNamed:@"meat_buy_bg"] forState:UIControlStateNormal];
        }
        
        button.tapBlock = ^{
            
            if (idx == 0) {
                NSLog(@"查看订单");
            }else{
                NSLog(@"继续逛逛");
            }
        };
        
        [self.view addSubview:button];
    }];
}

- (void)initData
{
    
}

#pragma mark - setter and getter

- (UIImageView *)successIcon{
    if (!_successIcon) {
        _successIcon = [[UIImageView alloc] init];
        _successIcon.size = CGSizeMake(60, 60);
        _successIcon.mj_y = 70;
        _successIcon.mj_x = (KScreenWidth - _successIcon.width)/2.0;
        _successIcon.image = [UIImage imageNamed:@"meat_complaints_selected"];
    }
    return _successIcon;
}

- (UILabel *)mainLab{
    if (!_mainLab) {
        _mainLab = [[UILabel alloc] init];
        _mainLab.text = @"支付成功";
        _mainLab.textColor = UIColorFromRGB(0x262626);
        _mainLab.font = mFont(21);
        _mainLab.textAlignment = NSTextAlignmentCenter;
        _mainLab.size = CGSizeMake(100, 29);
        _mainLab.mj_x = (KScreenWidth - _mainLab.width)/2.0;
        
    }
    return _mainLab;
}

- (UILabel *)detailLab{
    if (!_detailLab) {
        _detailLab = [[UILabel alloc] init];
        _detailLab.text = @"温馨提示：感谢您对小店的信任，如能付款（预定单），\n 我们会以短信形式通知您，请耐心等待！";
        _detailLab.textColor = UIColorFromRGB(0x999999);
        _detailLab.font = mFont(13);
        _detailLab.textAlignment = NSTextAlignmentCenter;
        _detailLab.size = CGSizeMake(KScreenWidth, 44);
        _detailLab.numberOfLines = 0;
        _detailLab.mj_x = (KScreenWidth - _detailLab.width)/2.0;
        
    }
    return _detailLab;
}


@end
